package day31;
import java.util.*;
public class A1 {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();//每个口罩的初始不舒适度
            int k = in.nextInt();
            int[] nums = new int[n];
            PriorityQueue<Integer> queue = new PriorityQueue<>();
            for(int i=0;i<n;i++) {
                nums[i]=in.nextInt();
                queue.add(nums[i]);
            }
            int sum=0,ret=0;
            while(sum<=k) {
                int pop = queue.poll(); //弹出最小值
                if(sum+pop>k) break;
                ret++;
                sum+=pop;
                queue.add(pop*2);
            }
            System.out.println(ret);
        }
    }

}
